package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PropertyChange;
import com.ruoyi.system.service.IPropertyChangeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资产变更情况Controller
 * 
 * @author kite
 * @date 2025-03-27
 */
@RestController
@RequestMapping("/system/change")
public class PropertyChangeController extends BaseController
{
    @Autowired
    private IPropertyChangeService propertyChangeService;

    /**
     * 查询资产变更情况列表
     */

    @GetMapping("/list")
    public TableDataInfo list(PropertyChange propertyChange)
    {
        startPage();
        List<PropertyChange> list = propertyChangeService.selectPropertyChangeList(propertyChange);
        return getDataTable(list);
    }

    /**
     * 导出资产变更情况列表
     */

    @Log(title = "资产变更情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyChange propertyChange)
    {
        List<PropertyChange> list = propertyChangeService.selectPropertyChangeList(propertyChange);
        ExcelUtil<PropertyChange> util = new ExcelUtil<PropertyChange>(PropertyChange.class);
        util.exportExcel(response, list, "资产变更情况数据");
    }

    /**
     * 获取资产变更情况详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(propertyChangeService.selectPropertyChangeById(id));
    }

    /**
     * 新增资产变更情况
     */

    @Log(title = "资产变更情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyChange propertyChange)
    {
        return toAjax(propertyChangeService.insertPropertyChange(propertyChange));
    }

    /**
     * 修改资产变更情况
     */

    @Log(title = "资产变更情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyChange propertyChange)
    {
        return toAjax(propertyChangeService.updatePropertyChange(propertyChange));
    }

    /**
     * 删除资产变更情况
     */

    @Log(title = "资产变更情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(propertyChangeService.deletePropertyChangeByIds(ids));
    }
}
